import { locale } from 'dayjs';
import 'dayjs/locale/zh-cn';
import 'dayjs/locale/en';
import { localStg } from '@/utils/storage';

/**
 * Set dayjs locale
 *
 * @param lang
 */
export function setDayjsLocale(lang: App.I18n.LangType = 'zh_CN') {
    const localMap = {
        zh_CN: 'zh_cn',
        en_US: 'en'
    } satisfies Record<App.I18n.LangType, string>;

    const l = lang || localStg.get('lang') || 'zh_CN';

    locale(localMap[l]);
}
